﻿package java_45;

import java.util.HashMap;
import java.util.Map;

import entity.Student;

public class HashMapDemo {

    /**
     * @param args
     */
    public static void main(String[] args) {
    
        Student student1 = new Student("李明", "男");
        Student student2 = new Student("刘丽", "女");
    
        Map<String,Student> students = new HashMap<String,Student>();
       
        students.put("Jack", student1);
        students.put("Rose", student2);
       
        System.out.println("键集："+students.keySet());
       
        System.out.println("值集："+students.values());
      
        System.out.println("键-值对集合:"+students);

        String key = "Jack";
       
        if(students.containsKey(key)){
          
            Student  student = students.get(key);
            System.out.println("学员姓名："+student.getName());
        }


    }

}